#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n,r[100000],cnt[100002]={0},ans=0,res=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&r[i]);
        cnt[r[i]]++;
    }
    for(int i=1;i<=100000;i++){
        if(cnt[i]>cnt[i+1]){
            res+=cnt[i]-cnt[i+1];
            ans+=cnt[i+1];
        }else{
            ans+=min(cnt[i+1],cnt[i]+res);
            res=max(res-(cnt[i+1]-cnt[i]),0);
        }
    }
    printf("%d",n-ans);
    return 0;
}
